import { Service } from "cl-admin";
import BaseService from "@/service/base";
import { last } from "cl-admin/utils";

@Service("OrderRefund")
class OrderRefund extends BaseService {
	// 售后/财务退款列表
	refundList({ time = [], time1 = [], time2 = [], dept_ids = [], size, bra_id = [], ...args }) {
		let params = {
			...args,
			pagesize: size,
			dept_id: dept_ids.join(),
			bra_id: bra_id.join()
		};
		// if (dept_ids && dept_ids.length) {
		//     params.dept_id = last(dept_ids)
		// }
		// 定金
		if (time && time.length) {
			params.consume_begin = time[0];
			params.consume_end = time[1];
		}
		// 退定
		if (time1 && time1.length) {
			params.refund_begin = time1[0];
			params.refund_end = time1[1];
		}
		// 打款
		if (time2 && time2.length) {
			params.payment_begin = time2[0];
			params.payment_end = time2[1];
		}
		return this.$get("/lists", { params }).then(res => {
			// console.log( this.pagination(params,res));
			return this.pagination(params, res);
		});
	}

	//售后退款详情
	refunddetail(params) {
		return this.$get('/refunddetail', { params })
	}

	// 售后通过操作
	afterpass(params) {
		return this.$post('/afterpass', params)
	}

	//售后退款常规审核
	routineoperate(params) {
		return this.$post('/routineoperate', params)
	}

	//财务打款
	financepayment(params) {
		return this.$post('/financepayment', params)
	}
	cancel(params) {
		return this.$post('/cancel', params)
	}
	// 银行卡类型
	bankType(params) {
		return this.$get('/bankType', { params })
	}
}

export default OrderRefund;
